<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>调查窗口页</title>
		<link rel="stylesheet" href="../../css/mui.min.css">
		<link rel="stylesheet" href="../../css/base.css">
		<style>
			body {
			}
			.base_add_icon {
				height: 20px;
				position: absolute;
				top: 50%;
				right: 15px;
				margin-top: -11px;
			}
		</style>
	</head>
	<body>
		<div class="base_style_color " id='BarAppearance' style="height: 22px;width: 100%"></div>
		<div class="base_navigation_bar base_style_color">
			<a class="base_left_item" href="#" onclick="back()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
			<span>签到</span>
			<a class="base_right_item nav-item" href="#" onclick="openCamera()" id="scan_div" style="display: none"> <img class="base_add_icon" src="../../image/icon_scan.png" alt="" > </a>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/push.js"></script>
	<script type="text/javascript" src="../../script/timeStampTool.js"></script>
	<script type="text/javascript" src="../../script/permission.js"></script>
	<script type="text/javascript">
		apiready = function() {
			setupSubframe();
			ReceNotifi();
		};
		//打开子页面
		function setupSubframe() {
			var y = $('.base_navigation_bar').height() + 22;
			var h = api.winHeight - y;
			api.openFrame({
				name : 'Student_signedWindow_LuDong',
				url : 'Student_signedWindow_LuDong.html',
				rect : {
					x : 0,
					y : y,
					w : 'auto',
					h : h
				},
				pageParam : {
					cid : api.pageParam.cid,
					pid : api.pageParam.pid,
					sourceurl : window.location.pathname,
					sourcetitle : document.title
				}
			});
		}

		function ReceNotifi() {
			api.addEventListener({
				name : 'pushMessage_classroomMessage'
			}, function(ret, err) {
				if (QD_TYPE == ret.value.type && $api.getStorage('cfnetppjxid') == ret.value.jid) {
					if (ret.value.status == 1) {
						$('#scan_div').show();
					} else {
						$('#scan_div').hide();
					}
				}
			});
			api.addEventListener({
				name : 'signSuccess'
			}, function(ret, err) {
				$('#scan_div').hide();
			});
			api.addEventListener({
				name : 'havesignNotifi'
			}, function(ret, err) {
				$('#scan_div').show();
			});
			api.addEventListener({
				name : 'haveNosignNotifi'
			}, function(ret, err) {
				$('#scan_div').hide();
			});
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				//coding...
				back();
			});
		}
		function openCamera() {

			checkPermission(['camera'],function (ret) {
				if(!ret){
					api.alert({
						title: '警告',
						msg: '相机权限申请失败，该功能无法使用，请到系统设置中打开相机权限'
					}, function(ret, err) {

					});
				}else {
					openQrcod();
				}
			});
		}
		//打开二维码扫描窗口
		function openQrcod() {
			var FNScanner = api.require('FNScanner');
			FNScanner.open({
				autorotation : true
			}, function(ret, err) {
				if (ret) {
					if (ret.eventType == "success") {
						api.sendEvent({
							name : 'openQrodeNotifi',
							extra : {
								content : ret.content,
								type : 1
							}
						});
					} else {
					}
				} else {
				}
			});
		}

		function back() {
			sendBuriedNotifi('1', '学生端签到页', '175');
			api.closeWin();
			// if (!api.pageParam.ismocc) {//自由课程列表过来
			// 	api.closeToWin({
			// 		name : 'Student_FreeCourseTab'
			// 	});
			// } else {
			// 	api.closeToWin({
			// 		name : 'Teacher_StudyCourseMoocTab'
			// 	});
			// }
		}

		function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}
	</script>
</html>